﻿
using System;
using System.Configuration;
using MockingBird.Common.Infrastructure.Configuration;

namespace MockingBird.Common.Infrastructure.Logging
{
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

    internal class LoggingConfigurationSource : IConfigurationSource
    {
        private string logFilePath;
        private const string loggingSectionName = "loggingConfiguration";

        #region IConfigurationSource Members
        internal LoggingConfigurationSource(string targetLogFilePath)
        {
            this.logFilePath = targetLogFilePath;

        }

        public void Add(IConfigurationParameter saveParameter, string sectionName, System.Configuration.ConfigurationSection configurationSection)
        {

        }

        public void AddSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler)
        {

        }

        public ConfigurationSection GetSection(string sectionName)
        {
            if (sectionName.Equals(loggingSectionName, StringComparison.CurrentCulture))
            {
                // return the section from the custom file
                ConfigurationSection loggingSection = ConfigurationUtils.GetConfigSection(logFilePath, loggingSectionName)
                                            as ConfigurationSection;

                return loggingSection;
            }

            return null;

        }

        public void Remove(IConfigurationParameter removeParameter, string sectionName)
        {

        }

        public void RemoveSectionChangeHandler(string sectionName, ConfigurationChangedEventHandler handler)
        {

        }

        #endregion
    }
}
